package com.dalin.platform.loa.action;

import java.util.List;

import java.util.List;

import com.dalin.framework.action.StrutsTwoAction;
import com.dalin.platform.loa.condition.LoaDicTypeCondition;
import com.dalin.platform.loa.model.LoaDicTypeEntity;
import com.dalin.platform.loa.service.LoaService;
import com.dalin.platform.loa.vo.LoaDicTypeVo;
/*****************************************************************************
 * @content: 类信息                                                   *
 * @author : 那建林                                                                                                                                 *
 * @crtDate: 2010-07-12                                                     *
 * @modDate: 2010-07-12                                                     *
 * @version: 1.00                                                           *
 ****************************************************************************/
public class DicTypeAddModAction extends StrutsTwoAction{
    private LoaService loaService; // 
    private LoaDicTypeVo vo; // 





    public String execute()throws Exception {
    	super.printInfo("", "===== this action begin");
        Long projectId = getCurrentUser().getProjectId();
        // 类型代码检查 begin
		LoaDicTypeCondition cond = new LoaDicTypeCondition();
		cond.setProjectId(projectId);
		cond.setTypeCode(vo.getTypeCode());
	    List<LoaDicTypeEntity> dataList = loaService
	    		.queryListByCond(cond.prepareParams());
	    if (dataList.size() > 0 && !dataList.get(0).getTypeId()
	    		 .equals(vo.getTypeId())) {
	    	setResContent(false, "类型代码重复,请您仔细检查");
	        return null;
	    }
        // 类型代码检查 over
        vo.setProjectId(projectId);
        if (vo.getTypeId() == null) {
            loaService.addLoaDicType(vo);
        } else {
            loaService.modifyLoaDicType(vo);
        }
        setResContent(true, "");
        super.printInfo("", "===== this action end");
        return null;
    }

    public LoaService getLoaService() {
        return loaService;

    }

    public void setLoaService(LoaService loaService) {
        this.loaService = loaService;

    }

    public LoaDicTypeVo getVo() {
        return vo;

    }

    public void setVo(LoaDicTypeVo vo) {
        this.vo = vo;

    }

}
